<?php

class Application_Form_Campanha extends Zend_Form
{	
    public function init()
    {    	
    	$t = Zend_Registry::get('translator');
    	
		$objLista = new Application_Model_Lista();
		$objFiltro = new Application_Model_Filtro();
		
        $this->setName('form_criar_campanha');
        $this->setAction('');
        $this->setMethod('post');
        
        $html = new Zend_Form_Element_Textarea('html');
        $html->setLabel($t->translate('MENSAGEM_CAMPANHA').':');
        $html->setValue($t->translate('BODY_HTML_CAMPANHA'));
        
        $nome = new Zend_Form_Element_Text('nome');
        $nome->setRequired(true);
        $nome->setAttribs(array('size'=>'70'));
        $nome->setLabel($t->translate('NOME_CAMPANHA').':');        
        
        $assunto = new Zend_Form_Element_Text('assunto');
        $assunto->setRequired(true);
        $assunto->setAttribs(array('size'=>'70'));
        $assunto->setLabel($t->translate('ASSUNTO_CAMPANHA').':');
        
        $remetente = new Zend_Form_Element_Text('remetente');
        $remetente->setRequired(true);
        $remetente->setAttribs(array('size'=>'70'));
        $remetente->addValidator(new Zend_Validate_EmailAddress());
        $remetente->setLabel($t->translate('REMENTENTE_CAMPANHA').':');
        
        $dataEnvio = new Zend_Form_Element_Text('dataenvio');
        $dataEnvio->setLabel($t->translate('DATAENVIO').':');
        $dataEnvio->setAttribs(array('size'=>'15'));
        $dataEnvio->setRequired(true);
        
        $hora = new Zend_Form_Element_Select('horaenvio');
        $hora->setLabel($t->translate('HORAENVIO').':');
        $hora->setRequired(true);
        $hora->setMultiOptions(array('00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23'));
        
        $minuto = new Zend_Form_Element_Select('minutoenvio');
        $minuto->setRequired(true);
        $minuto->setLabel(':');
        $minuto->setMultiOptions(array('00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50','51','52','53','54','55','56','57','58','59'));
        
        $lista = new Zend_Form_Element_Select('lista');
        $lista->setRequired(true);
        $listas = $objLista->fetchPair();
        $lista->addMultiOptions(array(''=>$t->translate('SELECIONE')));
        $lista->addMultiOptions($listas);
        $lista->setAttribs(array('onchange'=>"contaLista(this.value,'/admin/listas/conta-email-lista/');"));
        $lista->setLabel($t->translate('LISTA').':');
        
        $filtro = new Zend_Form_Element_Select('filtro');
        $filtro->setRequired(true);
        $filtro->addMultiOptions(array(''=>$t->translate('SELECIONE')));        
        $filtro->addMultiOptions($objFiltro->fetchPair());
        $filtro->setAttribs(array('disabled'=>'disabled','onchange'=>"contaEmailFiltro(document.getElementById('lista').value,this.value,'/admin/emails/conta-email/');"));
        $filtro->setLabel($t->translate('FILTRO').':');
        
        $botao = new Zend_Form_Element_Submit('Salvar');
        $botao->setAttribs(array('title'=>$t->translate('SALVAR'),'style'=>'font-weight:bold;'));
        $botao->setValue($t->translate('SALVAR'));
       
        $this->addElements(array($nome,$assunto,$remetente,$html,$dataEnvio,$hora,$minuto,$lista,$filtro,$botao));                
        $this->clearDecorators();
    }
}

